home *** CD-ROM | disk | FTP | other *** search
/ Champak 26 (Anniversary Edition) / Volume 26 [Anniversary Edition] - JOGO DISK .iso / DEPOSITO / sb_bust.swf / scripts / __Packages / Enemy1Obj.as < prev    next >
Text File  |  2006-07-26  |  10KB  |  371 lines

  1. class Enemy1Obj extends CharacterObj
  2. {
  3.    function Enemy1Obj(l_RefMov)
  4.    {
  5.       super(l_RefMov);
  6.       _global.C.G_Items.push(l_RefMov._name);
  7.       this.ComboNow = new Array(35);
  8.       this.Combos = new Array();
  9.       this.Combos.push(["PunchR",["Wait",30,35]]);
  10.       this.Combos.push(["PunchL",["Wait",30,35]]);
  11.       this.Combos.push(["PunchR",["Wait",30,35]]);
  12.       this.Combos.push(["PunchL",["Wait",30,35]]);
  13.       this.Combos.push(["PunchR","PunchL","PunchR",["Wait",30,20]]);
  14.       this.Combos.push(["SA",["Wait",40,40]]);
  15.       this.TimeToWait = 0;
  16.       this.TryParry = false;
  17.       this.TimeNoBloc = 0;
  18.       this.NoBloc = false;
  19.       this.CanBloc = true;
  20.       this.ChanceToParry = 70;
  21.       this.NbParry = 0;
  22.       this.MaxNbParry = 4;
  23.       this.Ripost = false;
  24.       this.ActionNow = "";
  25.       this.PunchRDammage = 5;
  26.       this.PunchLDammage = 5;
  27.       this.SADammage = 25;
  28.    }
  29.    function Wait()
  30.    {
  31.    }
  32.    function Idle()
  33.    {
  34.       if(this.WillWin)
  35.       {
  36.          this.RefMov._parent.EndLock.gotoAndStop(2);
  37.          this.State = "Win";
  38.       }
  39.    }
  40.    function StartParry()
  41.    {
  42.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  43.       {
  44.          this.State = "Parry";
  45.       }
  46.    }
  47.    function Parry()
  48.    {
  49.    }
  50.    function ParryBloc()
  51.    {
  52.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  53.       {
  54.          this.State = "EndParry";
  55.       }
  56.    }
  57.    function EndParry()
  58.    {
  59.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  60.       {
  61.          this.ReturnIdle();
  62.       }
  63.    }
  64.    function StartPunchR()
  65.    {
  66.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  67.       {
  68.          this.CanBloc = false;
  69.          this.State = "PunchR";
  70.       }
  71.    }
  72.    function PunchR()
  73.    {
  74.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  75.       {
  76.          this.CheckHit();
  77.          this.State = "EndPunchR";
  78.       }
  79.    }
  80.    function EndPunchR()
  81.    {
  82.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  83.       {
  84.          this.ReturnIdle();
  85.       }
  86.    }
  87.    function StartPunchL()
  88.    {
  89.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  90.       {
  91.          this.CanBloc = false;
  92.          this.State = "PunchL";
  93.       }
  94.    }
  95.    function PunchL()
  96.    {
  97.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  98.       {
  99.          this.CheckHit();
  100.          this.State = "EndPunchL";
  101.       }
  102.    }
  103.    function EndPunchL()
  104.    {
  105.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  106.       {
  107.          this.ReturnIdle();
  108.       }
  109.    }
  110.    function StartSA()
  111.    {
  112.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  113.       {
  114.          this.State = "DoSA";
  115.       }
  116.    }
  117.    function DoSA()
  118.    {
  119.       this.CheckHit();
  120.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  121.       {
  122.          this.State = "EndSA";
  123.       }
  124.    }
  125.    function EndSA()
  126.    {
  127.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  128.       {
  129.          this.ReturnIdle();
  130.       }
  131.    }
  132.    function GetHit()
  133.    {
  134.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  135.       {
  136.          this.CanBeHit = true;
  137.          this.ReturnIdle();
  138.       }
  139.    }
  140.    function GetSnail()
  141.    {
  142.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  143.       {
  144.          this.SetGetHit(_global.C.Garry.SADammage);
  145.          _global.C.Player.WinPts(_global.C.Garry.SAPts);
  146.          if(this.Health > 0)
  147.          {
  148.             this.CanBeHit = true;
  149.             this.ReturnIdle();
  150.          }
  151.          else
  152.          {
  153.             this.Health = 0;
  154.             this.State = "Die";
  155.          }
  156.       }
  157.    }
  158.    function Die()
  159.    {
  160.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes)
  161.       {
  162.          this.State = "Dead";
  163.          _global.C.Player.WillWin = true;
  164.       }
  165.    }
  166.    function Win()
  167.    {
  168.       if(this.RefMov.State._currentframe >= this.RefMov.State._totalframes and _global.Param._parent.RoundTransit._currentframe == 1)
  169.       {
  170.          _global.Param.G_Winner = this.Nom;
  171.          _global.Param.G_EnemyWin = _global.Param.G_EnemyWin + 1;
  172.          _global.Param._parent.RoundTransit.gotoAndPlay(2);
  173.       }
  174.    }
  175.    function CheckControl()
  176.    {
  177.       if(this.TimeToWait > 0)
  178.       {
  179.          this.TimeToWait = this.TimeToWait - 1;
  180.       }
  181.       if(!_global.C.G_RoundOver)
  182.       {
  183.          if(!this.NoBloc and this.CanBloc)
  184.          {
  185.             var _loc3_ = this.CheckParry();
  186.          }
  187.          else
  188.          {
  189.             _loc3_ = false;
  190.             this.NoBloc = false;
  191.          }
  192.          if(_loc3_)
  193.          {
  194.             this.NbParry = this.NbParry + 1;
  195.             if(this.NbParry > this.MaxNbParry)
  196.             {
  197.                this.Ripost = true;
  198.                if(random(100) < 50)
  199.                {
  200.                   this.ActionNow = "PunchL";
  201.                   this.State = "StartPunchL";
  202.                }
  203.                else
  204.                {
  205.                   this.ActionNow = "PunchR";
  206.                   this.State = "StartPunchR";
  207.                }
  208.             }
  209.             else
  210.             {
  211.                this.CanBeHit = false;
  212.                this.State = "StartParry";
  213.             }
  214.          }
  215.          else if(this.State == "Idle")
  216.          {
  217.             if(this.ComboNow.length == 0)
  218.             {
  219.                this.ChooseCombo();
  220.             }
  221.             if(this.TimeToWait == 0)
  222.             {
  223.                this.SetAction();
  224.             }
  225.          }
  226.       }
  227.    }
  228.    function ChooseCombo()
  229.    {
  230.       var _loc2_ = random(this.Combos.length);
  231.       this.ComboNow = this.Combos[_loc2_].slice(0);
  232.    }
  233.    function SetAction()
  234.    {
  235.       this.ActionNow = this.ComboNow.shift();
  236.       if(typeof this.ActionNow == "object")
  237.       {
  238.          if(this.ActionNow[0] == "Wait")
  239.          {
  240.             this.TimeToWait = this.ActionNow[1];
  241.             this.TimeNoBloc = this.ActionNow[2];
  242.          }
  243.       }
  244.       else
  245.       {
  246.          switch(this.ActionNow)
  247.          {
  248.             case "PunchR":
  249.                this.State = "StartPunchR";
  250.                break;
  251.             case "PunchL":
  252.                this.State = "StartPunchL";
  253.                break;
  254.             case "SA":
  255.                this.CanBloc = false;
  256.                this.CanBeHit = false;
  257.                this.State = "StartSA";
  258.                break;
  259.             case "TriPunch":
  260.                this.CanBloc = false;
  261.                this.CanBeHit = false;
  262.                this.State = "StartTriPunch";
  263.                break;
  264.             case "BiKick":
  265.                this.State = "BiKickPt1";
  266.                break;
  267.             case "Bounce":
  268.                this.CanBloc = false;
  269.                this.CanBeHit = false;
  270.                this.State = "StartBounce";
  271.          }
  272.       }
  273.    }
  274.    function CheckHit()
  275.    {
  276.       if(_global.C.Player.CanBeHit)
  277.       {
  278.          _global.C.Player.SetGetHit(this[this.ActionNow + "Dammage"]);
  279.       }
  280.       else if((_global.C.Player.ActionNow == "ParryR" or _global.C.Player.ActionNow == "ParryL") and _global.C.Player.AvoidAttack == "")
  281.       {
  282.          _global.C.Player.AvoidAttack = this.ActionNow;
  283.          _global.C.Player.PtSA += _global.C.Player.NbPtSAWin;
  284.          _global.C.Player.HaveParry = true;
  285.          if(_global.C.Player.PtSA > 100)
  286.          {
  287.             _global.C.Player.PtSA = 100;
  288.          }
  289.          _global.C._parent.Interface.PlayerSA.gotoAndStop(_global.C.Player.PtSA + 1);
  290.       }
  291.    }
  292.    function SetGetHit(l_Dammage)
  293.    {
  294.       this.CanBeHit = false;
  295.       this.Health -= l_Dammage;
  296.       _global.C.Player.PtSA += _global.C.Player.NbPtSAWin;
  297.       if(_global.C.Player.PtSA > 100)
  298.       {
  299.          _global.C.Player.PtSA = 100;
  300.       }
  301.       _global.C._parent.Interface.PlayerSA.gotoAndStop(_global.C.Player.PtSA + 1);
  302.       if(this.Health < 0)
  303.       {
  304.          this.Health = 0;
  305.       }
  306.       var _loc3_ = this.NbFace - int(this.Health * this.NbFace / this.MaxHealth);
  307.       this.RefMov._parent.Interface.EnemyFaces[this.Nom + "Face"].gotoAndStop(_loc3_);
  308.       if(this.Health > 0)
  309.       {
  310.          this.State = "GetHit";
  311.       }
  312.       else
  313.       {
  314.          _global.C.G_RoundOver = true;
  315.          this.State = "Die";
  316.       }
  317.    }
  318.    function SetGetHitGarry(l_Dammage)
  319.    {
  320.       this.CanBeHit = false;
  321.       this.Health -= l_Dammage;
  322.       if(this.Health < 0)
  323.       {
  324.          this.Health = 0;
  325.       }
  326.       var _loc3_ = this.NbFace - int(this.Health * this.NbFace / this.MaxHealth);
  327.       this.RefMov._parent.Interface[this.Nom + "Face"].gotoAndStop(_loc3_);
  328.       if(this.Health > 0)
  329.       {
  330.          this.ReturnIdle();
  331.       }
  332.       else
  333.       {
  334.          _global.C.G_RoundOver = true;
  335.          this.State = "Die";
  336.       }
  337.    }
  338.    function CheckParry()
  339.    {
  340.       if(this.TimeNoBloc == 0)
  341.       {
  342.          if(_global.C.Player.DoAttack and !this.TryParry)
  343.          {
  344.             this.TryParry = true;
  345.             if(random(100) <= this.ChanceToParry or this.NbParry == this.MaxNbParry)
  346.             {
  347.                return true;
  348.             }
  349.             return false;
  350.          }
  351.       }
  352.       this.TimeNoBloc = this.TimeNoBloc - 1;
  353.       return false;
  354.    }
  355.    function ReturnIdle()
  356.    {
  357.       if(typeof this.ComboNow[0] == "object" and this.ComboNow[0][0] == "Wait")
  358.       {
  359.          this.NoBloc = true;
  360.       }
  361.       if(this.ActionNow == "PunchR" or this.ActionNow == "PunchL" or this.ActionNow == "SA" or this.ActionNow == "TriPunch" or this.ActionNow == "BiKick" or this.ActionNow == "Bounce")
  362.       {
  363.          this.NbParry = 0;
  364.       }
  365.       this.Ripost = false;
  366.       this.CanBloc = true;
  367.       this.CanBeHit = true;
  368.       this.State = "Idle";
  369.    }
  370. }
  371.